package com.aierkeji.b2c.dao.jpa;

import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import com.aierkeji.b2c.dao.BaseJPADao;
import com.aierkeji.b2c.entity.AkjAlipayLife;
import com.aierkeji.b2c.entity.AkjProduct;
import com.aierkeji.b2c.entity.vo.ProductVo;

public interface AkjProductDao extends BaseJPADao<AkjProduct, String> {
	
	@Query("SELECT new com.aierkeji.b2c.entity.vo.ProductVo(t.id,t.akjAlipayLifeSnap.id,t.name,t.img.path,t.img.fileName,t.price,t.descript,t.activationTime) from AkjProduct t  join AkjAuser a on t.createBy = a.leaderId where t.id = :productId and t.delete = 0 and a.id=:salesId and a.isDelete=0")
	public ProductVo getProductVo(@Param("productId")String productId,@Param("salesId")String salesId);

	@Query("select a from AkjProduct a join a.akjAlipayLifeSnap t where a.id = :productId and a.delete =0 and t.delete = 0 ")
	AkjProduct findAkjProductByProductId(@Param("productId")String productId);
}
